.org 0xE5FD4 ; Cost Reduced

Cost_Reduced:

	PUSH 	{R4-R6, LR}
	
	LDR 	R3, [Cost_Reduced_1]
	LDR 	R2, [Cost_Reduced_2]
	LDR 	R4, [R3, 0]
	LDR 	R3, [R2, 0]
	MOV 	R2, 0x98
	ADD 	R3, R4, R3, LSL 2
	MUL 	R5, R0, R2
	LDR 	R3, [R3, 0x48]
	MOV 	R4, R1, LSL 4	
	ADD 	R0, R3, 0x5000	
	LDR 	R0, [R0, 0xA58]
	MOV 	R6, 0
	ADD 	R0, R0, R5
	ADD 	R0, R0, 0x74
	ADD 	R0, R0, R1, LSL 4
	
	MOV 	R1, Rank_Sale_Price					; Rank: Sale Price
	
	BL 		Check_Skills_Equipped				; Check the Skill is equipped
		
	CMP 	R0, 0								; Does CO use that skill?
	
	LDR 	R1, [Cost_Reduced_1]
	LDR 	R0, [Cost_Reduced_2]
	LDR 	R2, [R1, 0]
	LDR 	R0, [R0, 0]
	
	MOV 	R1, Rank_Fire_Sale					; Rank: Fire Sale	
	
	ADD 	R0, R2, R0, LSL 2
	LDR 	R0, [R0, 0x48]	
	
	SUBNE 	R6, R6, 5							; If CO use skill, reduce cost by -5

	ADD 	R0, R0, 0x5000	
	LDR 	R0, [R0, 0xA58]
	ADD 	R0, R0, R5
	ADD 	R0, R0, 0x74
	ADD 	R0, R0, R4
	
	BL 		Check_Skills_Equipped				; Check the Skill is equipped
	
	CMP 	R0, 0								; Does CO use that skill?
	SUBNE 	R6, R6, 8							; If CO use skill, reduce cost by -8
	
	MOV 	R0, R6
	POP 	{R4-R6, LR}
	
	BX 		LR

;-------------------------------------------------------------------------------		

Cost_Reduced_1:
	.dw Reg1_Skill
	
Cost_Reduced_2:
	.dw Reg2_Skill



